<template>
	<div class="currentVersion pd_50">
		<!-- 常见问题 -->
		<u-list lowerThreshold="200" @scrolltolower="pageAdd">
			<u-list-item v-for="(item, index) in lists" :key="index">
				<u-cell :title="item.title" :isLink="true" @click="goDetails(item)"> </u-cell>
			</u-list-item>
		</u-list>
	</div>
</template>

<script>
	import {
		cateLists,
		cateDetail
	} from "@/common/api/index";

	export default {
		name: "currentVersion",
		data() {
			return {
				lists: [],
				page: {
					page_no: 1,
					page_size: 20,
				},
				isEnd: false, //是否最后一页
			};
		},
		onLoad(options) {
			this.getList(options.id);
		},
		methods: {
			pageAdd() {
				this.page_no++;
				this.getList();
			},
			getList(id) {
				let arr = [];
				let formData = {
					cid: id,
					...this.page,
				};
				cateLists(formData).then((res) => {
					if (res.code === 1) {
						if (this.isEnd) {
							return;
						} else {
							this.lists = [...this.lists, ...res.data.lists];
							if (res.data.lists.length < 10) this.isEnd = true;
						}
					} else {
						this.showMsg(res.msg);
					}
				});
			},
			goDetails(item) {
				uni.navigateTo({
					url: `/pages/mine/article/questionDetail?item=${JSON.stringify(item)}`
				})
				console.log(item);
			},
		},
	};
</script>

<style scoped lang='scss'>
	.currentVersion {
		min-height: 100vh;
	}

	.mt_50 {
		margin-top: 50rpx;
	}

	.pd_50 {
		padding: 0 50rpx;
		box-sizing: border-box;
	}
</style>